package com.service;

import com.dao.UserDao;
import com.pojo.Role;
import com.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {
    @Resource
    private UserDao dao;

    public User login(String loginname,String password){
        return dao.login(loginname,password);
    }
    /*注册*/
    public int reg(String loginname,String password,String name,String sex,String email,String address){
       return dao.reg(loginname, password, name, sex, email, address);
    }
    /*根据用户名{查询*/
    public User querybyname(String loginname){
        return dao.querybyusername(loginname);
    }
    public int regist(User user){
        return dao.regist(user);
    }
    /*分页查询*/
    public List<User> queryFen(int pageindex,int pagesize){
        return dao.queryFen(pageindex, pagesize);
    }
    /*根据用户名查询*/
    public List<User> queryByUsername(String username,int pageindex,int pagesize){
        return dao.queryByUsername(username,pageindex,pagesize);
    }
    /*修改*/
    public int updateUser(User user){
        return dao.updateUser(user);
    }
    /*删除*/
    public int deleteUser(int id){
        return dao.deleteUser(id);
    }
    /*根据用户id查询*/
    public User queryByUserid(int id)
    {
        return dao.queryByUserid(id);
    }
    /*修改密码*/
    public int updatePass(String loginname,String oldpass,String newpass){
        return dao.updatePass(loginname,oldpass,newpass);
    }
    /*总数*/
    public int countall(String username){
        return dao.countAll(username);
    }
    public List<User> queryRole(int pageindex,int pagesize){
        return dao.queryRole(pageindex, pagesize);
    }
    public List<Role> queryRoleName(String rolename,int pageindex,int pagesize){
        return dao.queryRoleName(rolename,pageindex,pagesize);
    }
    public User queryToRole(String loginname){
        return dao.queryToRole(loginname);
    }
}
